#pragma once
#include "../lua/ELuna.h"
#include "../gge/ggebase.h"

using namespace ELuna;
bool Frame();
bool Exit();
bool FocusLost();
bool FocusGain();
bool Message(HWND h, UINT u, WPARAM w, LPARAM l);

extern bool				IsInit;
extern lua_State*		L ;
extern CRITICAL_SECTION g_cs;

namespace gge{typedef guint32 gUInt;}
class ggeBase
{
public:
	ggeBase(){}
	~ggeBase(){}

	bool		Engine_Create();
	void		Engine_Release();
	bool		System_Initiate();
	bool		System_Start();
	void		System_SetStateChar(int state ,const char *value);
	void		System_SetStateInt(int state ,int value);
	void		System_SetStateBool(int state ,bool value);
	void		System_SetStateFun(int state);
	void		System_NoWindow(bool value);
	int			System_GetStateInt(int state);
	bool		System_GetStateBool(int state);
	int			System_GetStateHwnd();
	const char*	System_GetStateChar(int state);
	void		System_Log(const char *format);
	bool		System_Launch(const char *url);

	ULONG		Resource_Load(const char *filename);
	const char*	Resource_ToText(int res);
	ULONG		Resource_GetSize(const char *filename);
	bool		Resource_IsExist(const char *filename);
	void		Resource_Free(ULONG res);
	ULONG		Resource_LoadTo(const char *filename,ULONG buf,ULONG size);
	bool		Resource_AttachPack(const char *filename, const char *password);
	void		Resource_RemovePack(const char *filename);
	void		Resource_AddPath(const char *filename);
	const char*	Resource_GetPackFirstFileName(const char *filename);
	const char*	Resource_GetPackNextFileName();

	void		Ini_SetFile(const char *filename);
	void		Ini_SetString(const char *section, const char *name, const char *value);
	const char* Ini_GetString(const char *section, const char *name, const char *def_val);

	float		Timer_GetTime();
	UINT		Timer_GetTick();
	float		Timer_GetDelta();
	int			Timer_GetFPS();

	void		Random_Seed(int seed);
	int			Random_Int(int min, int max);
	float		Random_Float(float min, float max);

	void		Graph_Clear(UINT color);
	bool		Graph_BeginScene(UINT texture);
	void		Graph_EndScene();
	void		Graph_GetRenderTarget(UINT texture);
	void		Graph_RenderLine(float x1, float y1, float x2, float y2, gge::gUInt color, float z);
	void		Graph_RenderQuad(float x1, float y1, float x2, float y2, gge::gUInt color, float z);
	void		Graph_SetClipping(int x , int y , int width , int height );
	void		Graph_SetTransform(float x , float y , float dx , float dy , float rot , float hscale, float vscale); 
	void		Graph_Snapshot(const char *filename,int format);
	void		Graph_RenderBatch(int primType, LuaTable vt, int primNum,UINT tex, int blend , bool bFilter);
	
	float 		Input_GetMousePosX();
	float 		Input_GetMousePosY();
	void		Input_SetMousePos(int x, int y);
	int			Input_GetMouseWheel();
	bool		Input_IsMouseOver();
	bool		Input_IsKeyPress(int key);
	bool		Input_IsKeyUp(int key);
	bool		Input_IsKeyDown(int key);
	bool		Input_IsMousePress(int key);
	bool		Input_IsMouseUp(int key);
	bool		Input_IsMouseDown(int key);
	int			Input_GetKey();
	const char* Input_GetChar();

	bool		Video_LoadFromFile(const char *filename);
	void		Video_Play();
	void		Video_Pause();
	void		Video_Stop();
	void		Video_Render();
	void		Video_RenderEx(float x, float y, float width, float height);
	bool		Video_IsPlaying();
	double		Video_GetPlayingTime();
	void		Video_SetVolume(int volume);



private:

};
